<?php
require_once 'SubfolderAccessManager/Acl.php';

class Zend_View_Helper_HasAccess extends Zend_View_Helper_Abstract
{
	protected $_acl;

	public function hasAccess($controller, $action)
	{
		if ($this->_acl == null) {
			$this->_acl = new SubfolderAccessManager_Acl();
		}
		$auth = Zend_Auth::getInstance();
		$role = 'guest';
		
		if ($auth->hasIdentity()) {
			$identity = $auth->getIdentity();
			$role = $identity->role;
		}
		if (!$this->_acl->has($controller)){
			return true;
		}
			
		if ($this->_acl->isAllowed($role, $controller, $action)){
			return true;
		} else {
			return false;
		}
		
		return false;
	}
}